<?php
/**
  *  @package ARXLib
  *  @version 2
  *  @subpackage Inputs
  *
  *  @copyright Ringo-Web Inc. 2004 - 2005
  */
require_once($_SERVER['DOCUMENT_ROOT']."/cms/libs/inputs/class.carxinput.php");
class CARXEdit extends CARXInput
{
	var $m_width;
	var $m_height;
	var $m_password;
	var $m_fieldId;
	
	function CARXEdit($label, $dbFieldName, $width = 24, $height = 1, $isPassword = FALSE, $addtag = "",$id=false)
	{
		parent::CARXInput($label, $dbFieldName);
		$this->m_width = $width;
		$this->m_height = $height;
		$this->m_password = $isPassword;
		$this->m_TagParams = $addtag;
		$this->m_fieldId=$id;
	
	}

	function GetHTML()
	{
		$htmlCtrlName = $this->GetHTMLCtrlName();
		//$value = htmlentities($this->m_value);
		$value = htmlspecialchars($this->m_value, ENT_QUOTES);

		if ($this->m_readonly || $this->m_printView)
		{
			$result = "<input type=\"hidden\" name=\"$this->m_dbFieldName\" id=\"$this->m_fieldId\" value=\"$value\"$this->m_TagParams>\n";
			if ($this->m_password)
			{
				for ($i = 0; $i < strlen($this->m_value); $i++)
				{
					$result .= "*";
				}
			}
			else
			{
				$result .= "$this->m_value\n";
			}
		}
		else
		{
			if ($this->m_password)
			{
				$result = "<input type=\"password\" name=\"$this->m_dbFieldName\" id=\"$this->m_fieldId\" value=\"$value\" size=\"$this->m_width\"$this->m_TagParams>\n";
			}
			else
			{
				if ($this->m_height == 1)
				{
					$result = "<input type=\"text\" name=\"$this->m_dbFieldName\" id=\"$this->m_fieldId\" value=\"$value\" size=\"$this->m_width\"$this->m_TagParams>\n";
				}
				else
				{
					$result = "<textarea name=\"$this->m_dbFieldName\" rows=\"$this->m_height\" cols=\"$this->m_width\"$this->m_TagParams >$value</textarea>\n";
				}
			}
		}
		return $result;
	}
}

?>